//
//  Tools.m
//  Bus
//
//  Created by wangjiajia on 13-7-30.
//  Copyright (c) 2013年 wangjiajia. All rights reserved.
//

#import "Tools.h"
#import "MBProgressHUD.h"
#import "Reachability.h"
#import "GCDiscreetNotificationView.h"
@implementation Tools

+(void)showHUD:(NSString *)text andView:(UIView *)view andHUD:(MBProgressHUD *)hud{
    
    [view addSubview:hud];
     hud.labelText=text;
     hud.square=YES;//是否正方形
    [hud show:YES];//是否动画显示
}


+(BOOL)isExistenceNetwork{
    BOOL isExistenceNetwork;
	Reachability *r = [Reachability reachabilityWithHostName:@"www.baidu.com"];
    switch ([r currentReachabilityStatus]) {
        case NotReachable:
			isExistenceNetwork=FALSE;
            NSLog(@"无网络连接");
            break;
        case ReachableViaWWAN:
			isExistenceNetwork=TRUE;
            NSLog(@"使用移动网络联接");
            break;
        case ReachableViaWiFi:
			isExistenceNetwork=TRUE;
            NSLog(@"使用无线热点联接");
            break;
    }
	return isExistenceNetwork;
   
}

+(void)toastNotification:(NSString *)text andView:(UIView *)view andLoading:(BOOL)isLoading andIsBottom:(BOOL)isBottom{
    GCDiscreetNotificationView *notificationView = [[GCDiscreetNotificationView alloc] initWithText:text showActivity:isLoading inPresentationMode:isBottom?GCDiscreetNotificationViewPresentationModeBottom:GCDiscreetNotificationViewPresentationModeTop inView:view];
    [notificationView show:YES];
    [notificationView hideAnimatedAfter:2.6];

}
+(void)toastNotification:(NSString *)text andView:(UIView *)view andLoading:(BOOL)isLoading andIsBottom:(BOOL)isBottom andHideTime:(NSTimeInterval) time{
    GCDiscreetNotificationView *notificationView = [[GCDiscreetNotificationView alloc] initWithText:text showActivity:isLoading inPresentationMode:isBottom?GCDiscreetNotificationViewPresentationModeBottom:GCDiscreetNotificationViewPresentationModeTop inView:view];
    [notificationView show:YES];
    [notificationView hideAnimatedAfter:time];
}
@end
